//
//  SGJSetupNewPasswordViewController.m
//  Sewage
//
//  Created by 宗庆猛 on 2017/5/30.
//  Copyright © 2017年 宗庆猛. All rights reserved.
//

#import "SGJSetupNewPasswordViewController.h"
#import "SGJSetupNewPasswordNextViewController.h"
#import "SGJNetworkTools.h"

#import "SGJTabController.h"

@interface SGJSetupNewPasswordViewController ()
@property (weak, nonatomic) IBOutlet UIView *LoginAccount;
@property (weak, nonatomic) IBOutlet UIView *GetVerifitionCode;
@property (weak, nonatomic) IBOutlet UITextField *LoginAccountTextField;
@property (weak, nonatomic) IBOutlet UITextField *VerifitionCodeTextField;
@property (weak, nonatomic) IBOutlet UIButton *NextstepButton;

@property (weak, nonatomic) IBOutlet UITextField *confirmPwdTextField;
@property (weak, nonatomic) IBOutlet UITextField *InputnewPwdTextField;


@end

@implementation SGJSetupNewPasswordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor colorWithWhite:.95 alpha:1];
    self.LoginAccount.layer.cornerRadius = 22;
    self.GetVerifitionCode.layer.cornerRadius = 22;
    self.NextstepButton.layer.cornerRadius = 22;
    // 取消输入框边线
    self.LoginAccountTextField.borderStyle = UITextBorderStyleNone
    ;
    self.VerifitionCodeTextField.borderStyle = UITextBorderStyleNone
    ;
    
    
}
-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBar.hidden = YES;
}
- (IBAction)ReturnButton:(id)sender {
     [self.navigationController popViewControllerAnimated:YES];
}
- (IBAction)GetVerificationCodeButton:(id)sender {
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    //params[@"type"] = @"";
    //zidong  type
    params[@"tel"] = self.LoginAccountTextField.text;//做判断
    //params[@"pwd"] = self.LoginPasswordTextField.text;
    
    [[SGJNetworkTools sharedNetworkTool] getSmsCodeWhenForgetPWDWithURLString:kThroughSmsToResetPwdUrl parameters:params method:@"POST" callBack:^(id responseObject) {
        if ([responseObject[@"retCode"] integerValue]==0) {
            NSLog(@"提示网络请求成功");
        }
    }];
    
}
- (IBAction)theNextStepButton:(id)sender {//完成
    ///v1/resetPwd	{tel:1875662,pwd:111111,checkCode:aeto }
    
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    
    params[@"tel"] = self.LoginAccountTextField.text;//做判断
    params[@"checkCode"] = self.VerifitionCodeTextField.text;
    if ([self.InputnewPwdTextField.text isEqualToString:self.confirmPwdTextField.text]) {
        params[@"pwd"] = self.confirmPwdTextField.text;//show
    }
    
    
    [[SGJNetworkTools sharedNetworkTool] resetPwdWithURLString:kResetPwdUrl parameters:params method:@"POST" callBack:^(id responseObject) {
        if ([responseObject[@"retCode"] integerValue]==0) {
            SGJTabController *tabVc = [[SGJTabController alloc] init];
            [self.navigationController pushViewController:tabVc animated:YES];
        }else{
            NSLog(@"重置密码失败");
        }
    }];
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
